using System;
using System.Collections;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Diagnostics;
using System.Globalization;

#if !PocketPC
using System.Reflection.Emit;
using System.Linq.Expressions;
#endif

namespace LightPersist
{
	public static class CommonUtils
	{

		
	

		public static string Arg(this string format, params object[] args)
		{
			return string.Format(CultureInfo.CurrentCulture, format, args).Replace('`', '"');
		}
		public static string ArgI(string format, params object[] args)
		{
			return string.Format(CultureInfo.InvariantCulture, format, args).Replace('`', '"');
		}

	}

	static class Debug
	{
		[Conditional("DEBUG"), DebuggerNonUserCode]
		public static void Assert(bool condition)
		{
			if(!condition)
			{
				throw new ApplicationException("Assertion Failed");
			}
		}

		[Conditional("DEBUG"), DebuggerNonUserCode]
		public static void AssertExists(object obj)
		{
			if(ReferenceEquals(obj, null))
			{
				throw new ApplicationException("Assertion Failed: Null BackReference");
			}
		}

		[Conditional("DEBUG")]
		public static void WriteLine(string format, params object[] args)
		{
			global::System.Diagnostics.Debug.WriteLine(string.Format(format, args));
		}
	}
}
